a = {
	@(x)	(-5 <= x & x <= -4) .* (0.00543517*x.^2 + 0.0688287*x.^1 + 0.246726) + ...
(-4 <= x & x <= -3) .* (0.0176974*x.^2 + 0.166926*x.^1 + 0.442921) + ...
(-3 <= x & x <= -2) .* (0.0245665*x.^2 + 0.208141*x.^1 + 0.504743) + ...
(-2 <= x & x <= -1) .* (0.264111*x.^2 + 1.16632*x.^1 + 1.46292) + ...
(-1 <= x & x <= 0) .* ( - 0.319049*x.^2 + 0.879762) + ...
(0 <= x & x <= 1) .* ( - 0.319049*x.^2 + 0.879762) + ...
(1 <= x & x <= 2) .* (0.264111*x.^2 - 1.16632*x.^1 + 1.46292) + ...
(2 <= x & x <= 3) .* (0.0245665*x.^2 - 0.208141*x.^1 + 0.504743) + ...
(3 <= x & x <= 4) .* (0.0176974*x.^2 - 0.166926*x.^1 + 0.442921) + ...
(4 <= x & x <= 5) .* (0.00543517*x.^2 - 0.0688287*x.^1 + 0.246726)
};
f = @(x) 1./(1 + x.^2);

x_values = linspace(-5, 5, 1000);
y_values_a = cellfun(@(func) func(x_values), a, 'UniformOutput', false);
y_values_f = f(x_values);
figure;
hold on;
for i = 1:numel(a)
    plot(x_values, y_values_a{i}, 'LineWidth', 2, 'DisplayName', sprintf('Segment %d', i));
end
plot(x_values, y_values_f, 'LineWidth', 2, 'DisplayName', '1/(1 + x^2)');
title('Comparison of Segmented Function and 1/(1 + x^2)');
xlabel('x');
ylabel('y');
legend('show');
grid on;
hold off;
